import Vue from 'vue';
import Child from './child'

export default Vue.component('parent',{
    template:`
        <div>
            <div>
                父级
                <input type="button" @click='btn' value="+1"/>
                <input type="button" @click="btn2" value="+3"/>
                {{num}}
            </div>
            <child ref='child' :parent='this'></child>
        </div>
    `,
    data(){
        return {
            num:0
        }
    },
    methods: {
        btn(){
            this.$refs.child.add();
        },
        btn2(){
            this.$refs.child.$emit('add_num',3)
        }
    },
})
